package cn.mengfly.fxtest.app;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
 * @author Mengfly
 */
public class GridPaneApp extends Application {



    @Override
    public void start(Stage primaryStage) {
        VBox vBox = new VBox();

        GridPane gp = new GridPane();
        Label lbl = new Label("Support Ticket");

        Label lblEmail = new Label("Email");
        TextField tfEmail = new TextField();

        Label lblPriority = new Label("Priority");
        ObservableList<String> priorities = FXCollections.observableArrayList("Medium", "High", "Low");
        ComboBox<String> cbPriority = new ComboBox<>(priorities);

        Label lblProblem = new Label("problem");
        TextField ftProblem = new TextField();

        Label lblDescription = new Label("Description");
        TextArea taDescription = new TextArea();

        gp.setPadding(new Insets(10));
        gp.setHgap(4);
        gp.setVgap(8);

        VBox.setVgrow(gp, Priority.ALWAYS);

        // empty item at 0, 0
        gp.add(lbl, 1, 1);

        gp.add(lblEmail, 0, 2);
        gp.add(tfEmail, 1, 2);

        gp.add(lblPriority, 0, 3);
        gp.add(cbPriority, 1, 3);

        gp.add(lblProblem, 0, 4);
        gp.add(ftProblem, 1, 4);

        gp.add(lblDescription, 0, 5);
        gp.add(taDescription, 1, 5);

        Separator sep = new Separator();
        ButtonBar buttonBar = new ButtonBar();
        buttonBar.setPadding(new Insets(10));

        Button saveButton = new Button("Save");
        Button cancelButton = new Button("Cancel");

        buttonBar.getButtons().addAll(saveButton, cancelButton);

        vBox.getChildren().addAll(gp, sep, buttonBar);

        Scene scene = new Scene(vBox);

        primaryStage.setTitle("Grid Pane App");
        primaryStage.setScene(scene);
        primaryStage.setWidth(736);
        primaryStage.setHeight(414);
        primaryStage.show();



    }
}
